﻿<Infrastructure:VisualStateAwarePage xmlns:Calendar="using:C1.Xaml.Calendar"  xmlns:Controls="using:EasySchedule.Controls"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="using:EasySchedule"
	xmlns:common="using:EasySchedule.Common"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"	
	xmlns:Infrastructure="using:Microsoft.Practices.Prism.StoreApps"	
	xmlns:Xaml="using:C1.Xaml"
    x:Name="pageRoot"
	x:Class="EasySchedule.Views.MainPageView"
	DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Mode=Self}}"	
	mc:Ignorable="d"
	Infrastructure:ViewModelLocator.AutoWireViewModel="true">
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>


        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape" />
                <VisualState x:Name="Filled" />

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}" />
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="100,126,90,0" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
					The back button and title have different styles when snapped, and the list representation is substituted
					for the grid displayed in all other view states
				-->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}" />
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Controls:AuthorizationView LogInCommand="{Binding LogInProxyCommand, Mode=TwoWay}"
			AuthorizationUrl="{Binding AuthorizationUrl}"
			x:Name="AuthorizationView" HorizontalAlignment="Center"
			VerticalAlignment="Center" Grid.Row="1" Height="500" Width="600"
			Visibility="Collapsed" />

        <!-- Horizontal scrolling grid used in most view states -->

        <Controls:ExtendedGridView
			x:Name="itemGridView"
			AutomationProperties.AutomationId="ItemGridView"
			AutomationProperties.Name="Items In Group"
			TabIndex="1"
			Grid.RowSpan="2"
			Padding="120,126,120,50"
			ItemsSource="{Binding Polls}"
			ItemTemplate="{StaticResource Standard500x130ItemTemplate}"
			SelectionMode="None"
			IsSwipeEnabled="false"
			IsItemClickEnabled="True"
			Command="{Binding OpenPollCommand}" Margin="0,40,0,0">

            <Controls:ExtendedGridView.Header>
                <StackPanel Width="600" >
                    <!--<TextBlock Text="{Binding Subtitle}" Margin="0,0,18,20" Style="{StaticResource SubheaderTextStyle}" MaxHeight="60" />
                    <Image Source="{Binding Image}" Height="400" Margin="0,0,18,20" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" />
                    <TextBlock Text="{Binding Description}" Margin="0,0,18,0" Style="{StaticResource BodyTextStyle}" />-->
                    <TextBlock Text="Doodle Calendar" HorizontalAlignment="Center" Margin="0,0,18,20" Style="{StaticResource SubheaderTextStyle}" MaxHeight="60" />
                    <!--<Viewbox Height="500">-->
                    <Calendar:C1Calendar Name="PollCalendar" Xaml:C1NagScreen.Nag="True" Height="500" />
                    <!--</Viewbox>-->
                </StackPanel>
            </Controls:ExtendedGridView.Header>
            <Controls:ExtendedGridView.ItemContainerStyle>
                <Style TargetType="FrameworkElement">
                    <Setter Property="Margin" Value="52,0,0,10" />
                </Style>
            </Controls:ExtendedGridView.ItemContainerStyle>
        </Controls:ExtendedGridView>

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
			x:Name="itemListView"
			AutomationProperties.AutomationId="ItemListView"
			AutomationProperties.Name="Items In Group"
			TabIndex="1"
			Grid.Row="1"
			Visibility="Collapsed"
			Padding="10,0,0,60"
			ItemsSource="{Binding Polls}"
			ItemTemplate="{StaticResource Standard80ItemTemplate}"
			SelectionMode="None"
			IsSwipeEnabled="false">

            <ListView.Header>
                <StackPanel>
                    <TextBlock Text="{Binding Subtitle}" Margin="10,0,18,20" Style="{StaticResource TitleTextStyle}" MaxHeight="60" />
                    <Image Source="{Binding Image}" Margin="10,0,18,0" MaxHeight="160" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" />
                    <TextBlock Margin="10,20,18,30" Text="{Binding Description}" Style="{StaticResource BodyTextStyle}" />
                </StackPanel>
            </ListView.Header>
        </ListView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140" />
                <ColumnDefinition Width="80*" />
                <ColumnDefinition Width="9*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" Margin="36,0,0,36" />
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}" Height="40" Foreground="{StaticResource TitleColor}" FontFamily="Impact" Grid.ColumnSpan="2" />
            <Button Content="login" Command="{Binding LogInCommand}" HorizontalAlignment="Right" Grid.Column="2" Margin="0,56,10,36" Height="48" Width="110" FontSize="20" />
        </Grid>
    </Grid>
    <Page.BottomAppBar>
        <AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button Style="{StaticResource EditAppBarButtonStyle}" />
                    <Button Style="{StaticResource RemoveAppBarButtonStyle}" />
                    <Button Style="{StaticResource AddAppBarButtonStyle}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Style="{StaticResource RefreshAppBarButtonStyle}" />
                    <Button Style="{StaticResource HelpAppBarButtonStyle}"/>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>

</Infrastructure:VisualStateAwarePage>
